<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户黑名单</title>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
    <style type="text/css">
        .layui-table-cell {
            height: 100%;
            max-width: 100%;
        }
    </style>
</head>
<body>
<div align="center">
    <h2>
        用户黑名单
    </h2>
</div>

<table id="userTable" lay-filter="userTable"></table>



<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">


    layui.use(['table','form','layer','laydate','upload'],function () {

        var table = layui.table;
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var upload = layui.upload;
        table.render({
            elem:'#userTable'
            ,url:'user/blacklist'
            ,page:true
            ,limit:6
            ,limits:[6,8,10,20]
            ,cols:[[
                {type:'checkbox'}
                ,{field:'id',title:'编号',sort:true, width:80, align:'center'}
                ,{field:'openid', title:'用户标识', align:'center'}
                ,{field:'username',title:'昵称', align:'center'}
                ,{field:'integral',title:'积分',sort:true, align:'center'}
                ,{field:'sex',title:'性别',align:'center',templet:function(d){
                        if(d.sex==2){
                            return '女'
                        }else if (d.sex==1){
                            return '男'
                        }else {
                            return '其它'
                        }
                    }}
                ,{field:'picPath',title:'头像',align:'center',templet:function (d) {
                        return "<img src='"+d.picPath+"' height='50px'/>";
                    }}
                ,{field:'country',title:'国家',align:'center'}
                ,{field:'province',title:'省份',align:'center'}
                ,{field:'city',title:'城市',align:'center'}
                ,{toolbar: '#barDemo', align:'center'}
            ]]
        });
        /**
         * 监听userTable的查看解封按钮的单击事件
         * */
        table.on('tool(userTable)',function (obj) {
            var data = obj.data;

            //解封按钮的单击事件
            if(obj.event=='del'){
                layer.confirm("你确定要解封该用户吗",{icon:'3',title:'提示'},function () {
                    $.ajax({
                        url:'user/unseal',
                        data:{id:data.id},
                        type:"post",
                        dataType:"json",
                        success:function (result) {
                            if(result.code==200){
                                table.reload("userTable",{
                                    page:{
                                        curr:1
                                    }
                                });
                                layer.msg("解封用户成功！",{icon:'1',title:'提示'});
                            }
                        }
                    });
                })
            }
        });





    });
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="del">解封</a>
</script>
</body>
</html>